package cn.merryyou.security.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * springsecurity 生成密码
 *
 * @author liucancan
 * @date 2018/12/19
 */
public class PasswordEncoderUtil {

    /**
     * 使用构造方法生成对象
     */
    private static PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();

    /**
     * 对密码使用BCryptPasswordEncoder加密方式进行加密
     */
    public static String passwordEncoder(String password) {
        return passwordEncoder.encode(password);
    }

    public static void main(String[] args) {
        System.out.println(passwordEncoder("123456"));
    }
}